<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="find.name">
                    </td>
                </tr>

                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="find.pwd">
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                       <input type="button" value="登录" @click="DL">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';

const find=ref({
    name:"",
    pwd:""
})

const DL=()=>{
    axios.get("https://localhost:7133/api/DL/DL",{params:find.value}).then(
        res=>{
            if(res.data.Id==-1){
                alert("用户名错误");
                return;
            }
            if(res.data.Id==-2){
                alert("密码错误");
                return;
            }
            if(res.data.Id>0){
                alert("登录成功");
                location.href='/list';
            }
        }
    )
}


</script>

<style scoped>

</style>